﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     UserField业务接口的实现
    /// 作者：     lwl
    /// 日期：     2011/11/11
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class UserFieldSqlMapDao : BaseSqlMapDao, IUserFieldDao
    {
        private static UserFieldSqlMapDao instance = null;
        private static object syncRoot = new object();

        private UserFieldSqlMapDao()
        {
            //
            // TODO: 此处添加UserFieldSqlMapDao的构造函数
            //
        }
        public static IUserFieldDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new UserFieldSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectUserFieldByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<UserField> GetList()
        {
            try
            {
                return ExecuteQueryForList<UserField>("SelectUserField", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<UserField> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<UserField>("SelectUserFieldByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="FieldID"></param>
        /// <returns></returns>
        public UserField GetDetail(System.String fieldid)
        {
            try
            {
                return ExecuteQueryForObject<UserField>("SelectUserField", fieldid) as UserField;
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 由其他参数得到明细
        /// </summary>
        /// <param name="DataID"></param>
        /// <returns></returns>
        public UserField GetDetail(UserField userField)
        {
            try
            {
                return ExecuteQueryForObject<UserField>("SelectUserField", userField) as UserField;
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="userfield"></param>
        /// <returns></returns>
        public object Add(UserField userfield)
        {
            //int id = GetId("UserField");
            //userfield.FieldID = id;

            try
            {
                return ExecuteInsert("InsertUserField", userfield);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="userfield"></param>
        /// <returns></returns>
        public int Update(UserField userfield)
        {
            try
            {
                return ExecuteUpdate("UpdateUserField", userfield);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="FieldID"></param>
        /// <returns></returns>
        public int Delete(System.String fieldid)
        {
            try
            {
                return ExecuteDelete("DeleteUserField", fieldid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="userfield"></param>
        /// <returns></returns>
        public int Delete(UserField userfield)
        {
            try
            {
                return ExecuteDelete("DeleteUserField", userfield.FieldID);
            }
            catch
            {
                throw;
            }
        }
    }
}
